#include <stdio.h>

int f(int *a, int *b, int *c)
{
	return *a * *b + *c;
}

int main()
{
	int a = 1, b = 2, c = 3;

	printf("%d\n", f(&a, &b, &c));	// 5
	return 0;
}

#if 0

note : 传递地址到函数的基本上都是指针

#endif

#if 0
/*
 * intel
 */
0000000000001169 <f>:
    1169:	f3 0f 1e fa          	endbr64 
    116d:	55                   	push   %rbp
    116e:	48 89 e5             	mov    %rsp,%rbp
    1171:	48 89 7d f8          	mov    %rdi,-0x8(%rbp)
    1175:	48 89 75 f0          	mov    %rsi,-0x10(%rbp)
    1179:	48 89 55 e8          	mov    %rdx,-0x18(%rbp)
    117d:	48 8b 45 f8          	mov    -0x8(%rbp),%rax
    1181:	8b 10                	mov    (%rax),%edx
    1183:	48 8b 45 f0          	mov    -0x10(%rbp),%rax
    1187:	8b 00                	mov    (%rax),%eax
    1189:	0f af d0             	imul   %eax,%edx
    118c:	48 8b 45 e8          	mov    -0x18(%rbp),%rax
    1190:	8b 00                	mov    (%rax),%eax
    1192:	01 d0                	add    %edx,%eax
    1194:	5d                   	pop    %rbp
    1195:	c3                   	retq   

0000000000001196 <main>:
    1196:	f3 0f 1e fa          	endbr64 
    119a:	55                   	push   %rbp
    119b:	48 89 e5             	mov    %rsp,%rbp
    119e:	48 83 ec 20          	sub    $0x20,%rsp
    11a2:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
    11a9:	00 00 
    11ab:	48 89 45 f8          	mov    %rax,-0x8(%rbp)
    11af:	31 c0                	xor    %eax,%eax
    11b1:	c7 45 ec 01 00 00 00 	movl   $0x1,-0x14(%rbp)
    11b8:	c7 45 f0 02 00 00 00 	movl   $0x2,-0x10(%rbp)
    11bf:	c7 45 f4 03 00 00 00 	movl   $0x3,-0xc(%rbp)
    11c6:	48 8d 55 f4          	lea    -0xc(%rbp),%rdx
    11ca:	48 8d 4d f0          	lea    -0x10(%rbp),%rcx
    11ce:	48 8d 45 ec          	lea    -0x14(%rbp),%rax
    11d2:	48 89 ce             	mov    %rcx,%rsi
    11d5:	48 89 c7             	mov    %rax,%rdi
    11d8:	e8 8c ff ff ff       	callq  1169 <f>
    11dd:	89 c6                	mov    %eax,%esi
    11df:	48 8d 3d 1e 0e 00 00 	lea    0xe1e(%rip),%rdi        # 2004 <_IO_stdin_used+0x4>
    11e6:	b8 00 00 00 00       	mov    $0x0,%eax
    11eb:	e8 80 fe ff ff       	callq  1070 <printf@plt>
    11f0:	b8 00 00 00 00       	mov    $0x0,%eax
    11f5:	48 8b 4d f8          	mov    -0x8(%rbp),%rcx
    11f9:	64 48 33 0c 25 28 00 	xor    %fs:0x28,%rcx
    1200:	00 00 
    1202:	74 05                	je     1209 <main+0x73>
    1204:	e8 57 fe ff ff       	callq  1060 <__stack_chk_fail@plt>
    1209:	c9                   	leaveq 
    120a:	c3                   	retq   
    120b:	0f 1f 44 00 00       	nopl   0x0(%rax,%rax,1)

/*
 * arm
 */
000000000040055c <f>:
  40055c:	d10083ff 	sub	sp, sp, #0x20
  400560:	f9000fe0 	str	x0, [sp, #24]
  400564:	f9000be1 	str	x1, [sp, #16]
  400568:	f90007e2 	str	x2, [sp, #8]
  40056c:	f9400fe0 	ldr	x0, [sp, #24]
  400570:	b9400001 	ldr	w1, [x0]
  400574:	f9400be0 	ldr	x0, [sp, #16]
  400578:	b9400000 	ldr	w0, [x0]
  40057c:	1b007c21 	mul	w1, w1, w0
  400580:	f94007e0 	ldr	x0, [sp, #8]
  400584:	b9400000 	ldr	w0, [x0]
  400588:	0b000020 	add	w0, w1, w0
  40058c:	910083ff 	add	sp, sp, #0x20
  400590:	d65f03c0 	ret

0000000000400594 <main>:
  400594:	a9be7bfd 	stp	x29, x30, [sp, #-32]!
  400598:	910003fd 	mov	x29, sp
  40059c:	52800020 	mov	w0, #0x1                   	// #1
  4005a0:	b9001fa0 	str	w0, [x29, #28]
  4005a4:	52800040 	mov	w0, #0x2                   	// #2
  4005a8:	b9001ba0 	str	w0, [x29, #24]
  4005ac:	52800060 	mov	w0, #0x3                   	// #3
  4005b0:	b90017a0 	str	w0, [x29, #20]
  4005b4:	910053a2 	add	x2, x29, #0x14
  4005b8:	910063a1 	add	x1, x29, #0x18
  4005bc:	910073a0 	add	x0, x29, #0x1c
  4005c0:	97ffffe7 	bl	40055c <f>
  4005c4:	2a0003e1 	mov	w1, w0
  4005c8:	90000000 	adrp	x0, 400000 <_init-0x3e8>
  4005cc:	911a4000 	add	x0, x0, #0x690
  4005d0:	97ffffa0 	bl	400450 <printf@plt>
  4005d4:	52800000 	mov	w0, #0x0                   	// #0
  4005d8:	a8c27bfd 	ldp	x29, x30, [sp], #32
  4005dc:	d65f03c0 	ret
#endif

